<template>
  <view class="page">
    <UserDate/>
    
    <view class="tcard">
      <view class="title">
        报告信息
      </view>
      <view class="tform">
        <view class="tform-item">
          <view class="value">检查项目</view>
          <view class="label">门诊电子病历</view>
        </view>
        <view class="tform-item">
          <view class="value">单号</view>
          <view class="label">435476789</view>
        </view>
        <view class="tform-item">
          <view class="value">科室</view>
          <view class="label">骨科</view>
        </view>
        <view class="tform-item">
          <view class="value">时间</view>
          <view class="label">2024-09-10 13:00</view>
        </view>
      </view>
    </view>
    
    <view class="tcard">
      <view class="title">
        <view class="">
          <text class="name">原始报告</text>
        </view>
      </view>
      <view class="wbv" style="position: relative;">
        <!-- <web-view :src="`/static/pdfjs/web/viewer.html?file=${url}`"></web-view> -->
        <iframe :src="`/wxapp/static/pdfjs/web/viewer.html?file=${url}`"></iframe>
      </view>
    </view>
  </view>
</template>

<script>
  import UserDate from '@/components/UserInfo/user-date.vue'
  export default {
    components: {UserDate},
    data() {
      return {
        url: ''
      }
    },
    onLoad() {
      this.viewFile()
    },
    methods: {
      viewFile() {
        uni.request({
          url: 'http://www.chim.org.cn/zzs/zzdt/202404/d28a113b30814ac190dd42c527f626bb/files/471150c5e39847afb32026c1e2f36fc2.pdf',
          method: "GET",
          responseType: 'arraybuffer',
          // header: {
          //   fileType: 'pdf',
          // },
          success: (response) => {
            console.log(999999, response)
            let pdfData = response.data; //pdfData是后端返回的文件流
            let blob = new Blob([ pdfData], {
              type: 'application/pdf;charset=UTF-8'
            })
            pdfData = window.URL.createObjectURL(blob) //创建预览路径
            this.url = encodeURIComponent(pdfData)
            console.log(pdfData)
          }
        });
      }
    }
  }
</script>

<style lang="scss" scoped>
.wbv {
  // position: relative;
  // height: 500upx;
  // width: 100%;
  iframe {
    width: 100%;
    height: 1000upx;
    border: none;
    outline: none;
  }
}
</style>
